const EventEmitter = require('events');
const util = require('util');

function Radio(name, frequency) {
  this.name = name;
  this.frequency = frequency;
}

util.inherits(Radio, EventEmitter);

Radio.prototype.play = function() {
  this.emit('open', this.name, this.frequency);
  setTimeout(() => {
    console.log('lalala...');
    this.stop();
  }, 2000);
};

Radio.prototype.stop = function() {
  this.emit('close', this.name, this.frequency);
};

module.exports = Radio;